@@ -10,7 +10,7 @@ my $build = Module::Build->new(
},
build_requires => {
'Module::Build' => 0,
- 'Test::Exception' => 0,
+ 'Test::Fatal' => 0,
'Test::More' => 0,
},
license => 'perl',
@@ -1,5 +1,10 @@
Revision history for ExtUtils-CChecker
+0.07 CHANGES:
+ * Use Test::Fatal instead of Test::Exception
+ * Advise against calling it "config.h" as that gets confused with
+ core perl's file
+
0.06 CHANGES:
* Added 'defines_to' constructor arg for writing a "config.h" file
instead of -DFOO on compiler commandline
@@ -11,4 +11,5 @@ t/01run.t
t/02assert.t
t/03accessors.t
t/04module_build.t
+t/05defines_to.t
t/99pod.t
@@ -4,7 +4,7 @@ author:
- 'Paul Evans <leonerd@leonerd.org.uk>'
build_requires:
Module::Build: 0
- Test::Exception: 0
+ Test::Fatal: 0
Test::More: 0
configure_requires:
Module::Build: 0.36
@@ -17,9 +17,9 @@ name: ExtUtils-CChecker
provides:
ExtUtils::CChecker:
file: lib/ExtUtils/CChecker.pm
- version: 0.06
+ version: 0.07
requires:
ExtUtils::CBuilder: 0
resources:
license: http://dev.perl.org/licenses/
-version: 0.06
+version: 0.07
@@ -311,15 +311,18 @@ EXAMPLES
including the kernel headers, which should make the constant and
structure visible, allowing the program to compile.
- Creating a config.h
+ Creating an "#include" file
Sometimes, rather than setting defined symbols on the compiler
commandline, it is preferrable to have them written to a C preprocessor
- include (.h) file.
+ include (.h) file. This may be beneficial for cross-platform portability
+ concerns, as not all C compilers may take extra "-D" arguments on the
+ command line, or platforms may have small length restrictions on the
+ length of a command line.
use ExtUtils::CChecker;
my $cc = ExtUtils::CChecker->new(
- defines_to => "config.h",
+ defines_to => "mymodule-config.h",
);
$cc->try_compile_run(
@@ -327,7 +330,7 @@ EXAMPLES
source => <<'EOF' );
#include <mango.h>
#include <unistd.h>
- #include "config.h"
+ #include "mymodule-config.h"
int main(void) {
if(mango() != 0)
exit(1);
@@ -335,9 +338,14 @@ EXAMPLES
}
EOF
- Because the config.h file is written and flushed after every define
- operation, it will still be useable in later C fragments to test for
- features detected in earlier ones.
+ Because the mymodule-config.h file is written and flushed after every
+ define operation, it will still be useable in later C fragments to test
+ for features detected in earlier ones.
+
+ It is suggested not to name the file simply config.h, as the core of
+ Perl itself has a file of that name containing its own compile-time
+ detected configuration. A confusion between the two could lead to
+ surprising results.
AUTHOR
Paul Evans <leonerd@leonerd.org.uk>
@@ -8,7 +8,7 @@ package ExtUtils::CChecker;
use strict;
use warnings;
-our $VERSION = '0.06';
+our $VERSION = '0.07';
use Carp;
@@ -527,11 +527,6 @@ sub new_module_build
return Module::Build->new( %args );
}
-# Keep perl happy; keep Britain tidy
-1;
-
-__END__
-
=head1 EXAMPLES
=head2 Socket Libraries
@@ -657,15 +652,18 @@ the F<libc> headers will be sufficient. If it fails, it will then try
including the kernel headers, which should make the constant and structure
visible, allowing the program to compile.
-=head2 Creating a F<config.h>
+=head2 Creating an C<#include> file
Sometimes, rather than setting defined symbols on the compiler commandline, it
is preferrable to have them written to a C preprocessor include (F<.h>) file.
+This may be beneficial for cross-platform portability concerns, as not all C
+compilers may take extra C<-D> arguments on the command line, or platforms may
+have small length restrictions on the length of a command line.
use ExtUtils::CChecker;
my $cc = ExtUtils::CChecker->new(
- defines_to => "config.h",
+ defines_to => "mymodule-config.h",
);
$cc->try_compile_run(
@@ -673,7 +671,7 @@ is preferrable to have them written to a C preprocessor include (F<.h>) file.
source => <<'EOF' );
#include <mango.h>
#include <unistd.h>
- #include "config.h"
+ #include "mymodule-config.h"
int main(void) {
if(mango() != 0)
exit(1);
@@ -681,10 +679,18 @@ is preferrable to have them written to a C preprocessor include (F<.h>) file.
}
EOF
-Because the F<config.h> file is written and flushed after every define
-operation, it will still be useable in later C fragments to test for features
-detected in earlier ones.
+Because the F<mymodule-config.h> file is written and flushed after every
+define operation, it will still be useable in later C fragments to test for
+features detected in earlier ones.
+
+It is suggested not to name the file simply F<config.h>, as the core of Perl
+itself has a file of that name containing its own compile-time detected
+configuration. A confusion between the two could lead to surprising results.
=head1 AUTHOR
Paul Evans <leonerd@leonerd.org.uk>
+
+=cut
+
+0x55AA;
@@ -2,19 +2,19 @@
use strict;
use Test::More tests => 2;
-use Test::Exception;
+use Test::Fatal;
use ExtUtils::CChecker;
my $cc = ExtUtils::CChecker->new;
-lives_ok(
- sub { $cc->assert_compile_run( source => "int main(void) { return 0; }\n", diag => "OK source" ); },
+ok(
+ !exception { $cc->assert_compile_run( source => "int main(void) { return 0; }\n", diag => "OK source" ); },
'Trivial C program'
);
-throws_ok(
- sub { $cc->assert_compile_run( source => "int foo bar splot\n", diag => "broken source" ); },
+like(
+ exception { $cc->assert_compile_run( source => "int foo bar splot\n", diag => "broken source" ); },
qr/^OS unsupported - broken source$/,
'Broken C program does not compile and run'
);
@@ -2,7 +2,6 @@
use strict;
use Test::More tests => 4;
-use Test::Exception;
use ExtUtils::CChecker;
@@ -0,0 +1,27 @@
+#!/usr/bin/perl -w
+
+use strict;
+use Test::More tests => 5;
+
+use ExtUtils::CChecker;
+
+my $cc = ExtUtils::CChecker->new(
+ defines_to => "test-config.h",
+);
+
+END { -e "test-config.h" and unlink "test-config.h"; }
+
+ok( defined $cc, 'defined $cc' );
+isa_ok( $cc, "ExtUtils::CChecker", '$cc' );
+
+$cc->try_compile_run(
+ source => "int main(void) { return 0; }\n",
+ define => "HAVE_C",
+);
+
+is_deeply( $cc->extra_compiler_flags, [], 'extra_compiler_flags does not have -D' );
+
+ok( -e "test-config.h", 'test-config.h exists' );
+
+open my $fh, "<", "test-config.h" or die "Cannot read test-config.h - $!";
+is( scalar <$fh>, "#define HAVE_C /**/\n", 'test-config.h has #define HAVE_C' );